<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\BillboardPic;
use App\Models\Billboard;

class BillboardPicController  extends Controller
{
    
    public function thumb(Request $request)
    {
        $rs['status'] = 'danger';
        $rs['msg'] = '操作失败';
        $id = $request->billboard_id;
        $pic = $request->pic;
        $billboard = Billboard::find($id);
        $billboard->thumb = $pic;
        $flag = $billboard->save();
        if ($flag) {
            $rs['status'] = 'success';
            $rs['msg'] = '操作成功';
            return back()->with('rs',$rs);
        }
        return back()->with('rs',$rs);


    }

    public function delete($id)
    {
        $rs['status'] = 'danger';
        $rs['msg'] = '操作失败';
        $flag = BillboardPic::where(['id'=>$id])->delete();
        if ($flag) {
            $rs['status'] = 'success';
            $rs['msg'] = '操作成功';
            return back()->with('rs',$rs);
        }
        return back()->with('rs',$rs);
    }
}
